Connecting to a Remote Serial Port over TCP/IP

Most modern machines don't have a serial port as standard; you could use a USB to serial lead, however, if you have another machine available that does have a serial port you can access it remotely over TCP/IP.

Using ser2net to Connect a Serial Port to a TCP port

ser2net listens to a TCP port and pipes data to and from a serial port via the TCP port. It is configured by the file /etc/ser2net.conf and is run on the machine with the serial port that you want to make available over TCP/IP. An example configuration file would look like this:

3333:raw:0:/dev/ttyS0:115200 8DATABITS NONE 1STOPBIT

This would tell ser2net to create a link between TCP port 3333 and /dev/ttyS0. The serial port would be configured to 115200 baud, 8 data bits, no parity and 1 stop bit.

Once you have created the configuration file you can either start ser2net by running:

$ ser2net

or if you have started it as a service you may need do something like:

$ /etc/init.d/ser2net restart

or if using systemd:

$ systemctl restart ser2net

From this point I'll refer to the machine with the serial port as SerialMachine. If you connect to port 3333 on SerialMachine, whatever you send or receive to/from that port will actually be to/from the serial port on SerialMachine.

Accessing a Remote Serial Port from DOSBox

A common use for this would to be to access a serial port form an emulator. To access a remote serial port, that has been set up as above, from DOSBox you would need the following line in your dosbox.conf file:

serial1=nullmodem server:SerialMachine port:3333

Now, whenever you use COM1 from within DOSBox, you'll actually be using the serial port on SerialMachine.

Using socat to Connect a Pseudo TTY to a Remote Serial Port

If the application you want to use doesn't know how to talk to serial ports over TCP/IP you can use socat. This is an incredibly flexible utility and can even replicate much of the functionality of ser2net, however it is a little more difficult to use, hence the reason that I have combined the two utiltiies. To create a psuedo tty device called ~/dev/ttyV0 and connect it to the remote serial port on SerialMachine run :

$ socat pty,link=$HOME/dev/ttyV0,waitslave tcp:SerialMachine:3333

This will then allow you to specify ~/dev/ttyV0 as the device name in an application such as minicom.

Where Now?

ser2net and socat are available on most Linux distributions, but if yours doesn't provide a package then they are fairly easy to download and install from their home pages. If you are not sure what to do with the new serial ports that you now have access to, why not hook-up a modem and see what BBS's are still around.

Creative Commons License
Connecting to a Remote Serial Port over TCP/IP by Lawrence Woodman is licensed under a Creative Commons Attribution 4.0 International License.

Share This Post

Feedback/Discuss

Related Articles

Transferring Files to and from CP/M .D71 Disk Images Using ctools

Using Vice to emulate a Commodore 128 running CP/M works very well, but it isn't easy to get CP/M files directly onto and off a .D64/.D71 disk image. The easiest way to do this under Linux is to use c...   Read More

Emulating a CP/M System With z80pack

z80pack is great for creating an emulated CP/M system. It can either be used to create a general CP/M system or can emulate a specific system such as an IMSAI or ALTAIR including a graphical front-pan...   Read More

Using C-Kermit to Exchange Files With Telnet BBS's

Most BBSs that are still running now do so via telnet. In many ways this is great as it allows people from all around the world to access a BBS as if it were local to them. The problem comes though, ...   Read More

xAce is Back in Active Development and Looking For Contributors

xAce is a great Jupiter Ace emulator and is in fact the one that I use the most, however it hasn't been actively developed since 1997 and therefore has some shortcomings. I am keen to improve the emul...   Read More

Getting Colour ANSI Emulation to Work Properly When Connecting to a BBS With Telnet Under Linux

I have noticed that the number of people interested in using telnet to access BBSs seems to be growing, which I'm really pleased to see. However lots of people seem to be having trouble getting colour...   Read More